package com.example.cdmuseum.ui.activity;

import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.example.cdmuseum.R;
import com.example.cdmuseum.base.BaseActivity;
import com.example.cdmuseum.bean.BoutiqueGv;
import com.example.cdmuseum.ui.adapter.BoutiqueHomeListAdapter;

import java.util.LinkedList;
import java.util.List;

import butterknife.BindView;

/**
 * BoutiqueHomeActivity
 * 精品首页
 */
public class BoutiqueHomeActivity extends BaseActivity {
    @BindView(R.id.rl_back)
    RelativeLayout back;


    @BindView(R.id.img_icon)
    ImageView img_icon;

    @BindView(R.id.tv_title)
    TextView tv_title;


    @BindView(R.id.tv_show_list)
    TextView tv_show_list;

    private List<BoutiqueGv> mData = null;
    private BoutiqueHomeListAdapter mAdapter = null;
    //
    @BindView(R.id.gv_data)
    GridView list_animal;


    String title;

    int img_id = 0;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_boutique_home;
    }

    @Override
    protected void init() {
        Intent intent = getIntent();
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        initData();

        title = intent.getStringExtra("title");
        img_id = intent.getIntExtra("index", 0);
        if (img_id != 0) {
            img_icon.setImageResource(img_id);
        } else {
            img_icon.setImageResource(R.drawable.boutique_1);
        }
        tv_title.setText(title);
        tv_show_list.setText(title + "列表");
    }

    public void initData() {
        mData = new LinkedList<BoutiqueGv>();
        mData.add(new BoutiqueGv("唐三彩三足罐", "三彩三足罐为低温釉陶器，敞口，卷唇，短颈，扁圆腹，腹部中间凸起一周宽条带，三兽形足均匀分布。里外涂化妆土，从肩部到腹部中间施绿、白、褐三彩，纹饰共分两层，上层褐、绿两色交替“人”字纹，下层为三彩星点纹，釉色在受热过程中自然流淌，三种颜色互相浸润交融，形成星光点点，灿烂夺目的色彩。器物造型敦厚、稳重。", R.drawable.p1_1));
        mData.add(new BoutiqueGv("清石湾米白釉砾石纹海棠式梅瓶", "器身呈四瓣海棠花形，圆唇，直颈，丰肩，束胫，足部稍外撇。整件器物为米白釉砾石纹，釉厚而光润，有小开片，圈足内白釉泛黄，并粘有砂粒。\n", R.drawable.p1_2));
        mData.add(new BoutiqueGv("现代石湾窑石榴红釉狮（一对）", "作者采用大胆夸张的手法来刻画这对狮子，其双目圆睁，张口露齿，尾巴蓬松，一只前爪伏地昂首，一只半坐回首，动感十足，配以石榴红釉，充分表现出狮子勇猛、活泼的神态。", R.drawable.p1_3));
        mData.add(new BoutiqueGv("清石湾窑红釉达摩立像", "达摩身穿长袍，双眼圆睁，两手放于胸前袖内，脸部及裸露肌体部分不施釉，面部表情刻画传神。全身施石榴红釉，釉厚色纯；衣物线条刚劲圆活，造型古拙庄重。雕塑手法纯熟简练，充分展现了石湾陶塑的艺术风格。", R.drawable.p1_4));
        mData.add(new BoutiqueGv("清石湾窑黄炳塑素胎熊、鹰", "熊、鹰通体以胎毛技法塑造，分踞于一红木几座上。熊龇牙咧嘴，双目圆睁，尾反卷至脊上；四肢、脊梁、眉毛及下颔等有卷毛的部位以石墨着色，并点上白珠，四爪白甲。鹰双目锐利晶亮，以黑漆点眼珠；全身羽毛为素胎加珍珠白点，点下一晕赭色衬底；爪、喙以石墨着色，两作品均钤有“雲渔氏”篆书文长方章。黄炳是清代中后期石湾陶塑名家，字雲渠，又号“雲渔氏”，精于塑造鸭、猫、猴等动物，开创“胎毛”技法表现动物纹饰形态，细腻逼真，惟妙惟肖，为后人所取法。\n", R.drawable.p1_5));

        mAdapter = new BoutiqueHomeListAdapter((LinkedList<BoutiqueGv>) mData, this);
        list_animal.setAdapter(mAdapter);
        list_animal.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Toast.makeText(getApplicationContext(), "点击" + i, Toast.LENGTH_SHORT).show();
                Intent intent = new Intent(BoutiqueHomeActivity.this, BoutiqueHomeDetailActivity.class);
                intent.putExtra("img", mData.get(i).getaIcon());
                intent.putExtra("show_name", mData.get(i).getaName());
                intent.putExtra("description", mData.get(i).getaSpeak());
                intent.putExtra("index", i);
                startActivity(intent);
            }
        });
    }


}